import axios from 'axios'
const http=axios.create({
  timeout:50000,
   baseURL: "http://25q686n876.qicp.vip",
})
// 1.给实例添加请求拦截
http.interceptors.request.use((request)=>{
  // 设置请求头
  request.headers['token']='';
  return request
},(error)=>{
  console.log(error);
  return error;
})
// 2.添加响应拦截
http.interceptors.response.use((response)=>{
  return new Promise((resolve,reject)=>{
    if(response.data.code === -1){
      reject(response.data)
    }else{
      resolve(response.data)
    }
  })
},(error)=>{
console.log(error);
return error
})

export default http;